function weaponeffects.init()
can_sound1 = load_particle("can_bounce_soundgen.obj")
grenade_sound2 = load_particle("grenade_bounce_soundgen.obj")
shell_sound = load_particle("shell_bounce_soundgen.obj")


	function bindings.playerInit(player)
		player:data().white_flash = 0
	end
	
	function bindings.wormDeath(worm)
		worm:player():data().white_flash = 0
	end

	function bindings.playerUpdate(player)
		if player:data().white_flash > 0 then
			player:data().white_flash = player:data().white_flash - 4
		end
		
		if player:data().white_flash < 0 then
			player:data().white_flash = 0
		end
	end

	function bindings.viewportRender(viewport, worm)
		local bitmap = viewport:bitmap()
		local player = worm:player()
		
		if player:data().white_flash >= 0 and worm:health() > 0 then
			gfx_set_add(player:data().white_flash)
			bitmap:draw_box(0, 0, 320, 240, color(150,150,150))
			gfx_reset_blending()
		end
	end
	
	function weaponeffects.white_flash_large(object,target)
		local player = target:player()
		local worm = player:worm()
		local ox,oy = object:pos()
		local x,y = worm:pos()

		--print(vector_distance(ox,oy,x,y))
		player:data().white_flash = player:data().white_flash + (150-vector_distance(ox,oy,x,y)*1.5)

		--print(player:data().white_flash)

		if player:data().white_flash > 150 then
			player:data().white_flash = 150
		end
	end
	
	function weaponeffects.white_flash_small(object,target)
		local player = target:player()
		local worm = player:worm()
		local ox,oy = object:pos()
		local x,y = worm:pos()

		--print(vector_distance(ox,oy,x,y))
		player:data().white_flash = player:data().white_flash + (150-vector_distance(ox,oy,x,y)*2)

		--print(player:data().white_flash)

		if player:data().white_flash > 100 then
			player:data().white_flash = 100
		end
	end
	
	function weaponeffects.white_flash_minimal(object,target)
		local player = target:player()
		local worm = player:worm()
		local ox,oy = object:pos()
		local x,y = worm:pos()

		--print(vector_distance(ox,oy,x,y))
		player:data().white_flash = player:data().white_flash + (100-vector_distance(ox,oy,x,y)*2)

		--print(player:data().white_flash)

		if player:data().white_flash > 40 then
			player:data().white_flash = 40
		end
	end

	function weaponeffects.can_sound(object)
		if vector_distance( object:spd() ) > 0.5 then
			object:shoot(can_sound1, 1, 0, 0, 0, 0, 0, 0, 0)
		end
	end
	
	function weaponeffects.grenade_sound(object)
		if vector_distance( object:spd() ) > 0.5 then
			object:shoot(grenade_sound2, 1, 0, 0, 0, 0, 0, 0, 0)
		end
	end
	
	function weaponeffects.shell_sound(object)
		if vector_distance( object:spd() ) > 0.2 then
			object:shoot(shell_sound, 1, 0, 0, 0, 0, 0, 0, 0)
		end
	end

	function bindings.wormRender(x, y, worm, viewport, ownerPlayer)
		local player = worm:player()
		local ownViewport = ( ownerPlayer == worm:player() )
		local bitmap = viewport:bitmap()
		
		--if ownViewport then
			if worm:current_weapon():type():name() == "Rifle" then
				if worm:current_weapon():is_reloading() == false then
					local range = 650
					local decr = range
					local temp = 0
					local tx,ty = worm:pos()
						
					while decr > 0 do
						local dx, dy = angle_vector(worm:angle(), decr)
						--bitmap:line(x,y,x+dx,y+dy,color(255,0,0))
							
						if map_is_blocked(tx,ty,tx+dx,ty+dy) then
							decr = decr - 5
						else			
							for i=1,40 do
								temp = randomint(8,range)
								if temp <= decr then
									dx, dy = angle_vector(worm:angle(), temp)
									gfx_set_add(255)
									bitmap:putpixelwu(x+dx,y+dy,color(255,0,0))
									gfx_reset_blending()
								end
							end
								
							break
						end
					end
				end
			end
		--end
	end

end